package shoot.FlyingObject;

import java.awt.image.BufferedImage;
import java.util.Random;

/**
 * @author: dongshipan
 * @date: 2021/7/5 17:03
 * @description:
 */
public class Bee extends BaseFlyingObject{
    private static BufferedImage[] images;

    static {
        images = new BufferedImage[5];
        images[0] = readImage("bee0.png");
        for (int i = 1; i < images.length; i++) {
            images[i] = readImage("bom" + i + ".png");
        }
    }

    private int xStep;

    //横向移动速度
    private int yStep;
    // 纵向移动速度
    private int awardType;
    // 奖励类型 0 为火力值，1 为生命值
    // 60 51
    public Bee() {
        super(60, 51);
        Random ran = new Random();
        //横向速度
        xStep = 1;
        // 纵向速度
        yStep = 2;
        //奖励类型，随机 0 或 1
        // awardType = ran.nextInt(2);
    }

    @Override
    public void step() {
        y += yStep;
        //横向移动
        x += xStep;
        // 检测是否碰壁
        // if (x <= 0 || x >= World.WIDTH - width) {
        //     //如果碰壁，xStep 更换符号（正负号），切换移动方向
        //     xStep *= -1;
        // }
    }
    /**
     * 实现奖励类型
     */
    // public int getAwardType() {
    //     return awardType;
    // }

    int index = 0;


    @Override
    public BufferedImage getImage() {
        if (isLife()) {
            return images[0];
        } else if (isDead()) {
            index++;
            if (index == images.length - 1) {
                state = FlyConstant.REMOVE;
            }
            return images[index];
        }
        return null;
    }
}
